1. Technical Field
The present invention relates to assembly programming in general, and in particular to structured assembly language programming. Still more particularly, the present invention relates to an IF construct having an expression setup clause to be utilized in structured assembly language programming.
2. Description of the Prior Art
Structured assembly language programming is an improvement to the basic syntax of conventional assembly language programming. In essence, structured assembly language programming allows the use of structured programming constructs similar to those generally found in high-level programming languages such as Pascal or C.
One of the structured programming constructs is the well-known IF construct. It consists of an IF clause followed by zero or more ELSE—IF clauses, an optional ELSE clause, and an END—IF statement. The simplest structured assembly language IF construct is typically utilized as follows:
condition setup assembly language codeIF (condition)conditionally executed assembly language codeEND—IFunassociated with IF assembly language codewhere condition contains structured assembly language expression(s) for generating comparison opcodes (i.e., opcodes that set the processor's flags) and/or branch opcodes. Only comparison opcodes and branch opcodes are used in the implementation of a structured assembly language expression. An assembler then converts the above-mentioned structured assembly language IF construct to a group of processor opcodes as follows (in assembler mnemonics):
condition setup assembly language codecmp r0,#7 ; (r0 == 7) ∥ (r1 < r2)bnz falselabelcmp r1,r2bge falselabelconditionally executed assembly language codefalselabel equ $In this example, the condition compares a processor register to a numeric value, and a comparison also occurs between two processor registers. The condition is (r0==7) or (r1<r2). One important difference between a structured assembly language IF construct and an IF construct from a high-level programming language is that a programmer is responsible for register setup so the structured assembly language expression, that is the condition, is only made up of comparison opcodes and/or branch opcodes. In fact, such kind of optimization capability is a key reason for choosing assembly language in the first place. The need to execute opcodes to setup for a structured assembly language expression is a real problem when multiple conditions must be tested. In order to test many different conditions using structured assembly language under the prior art, a nested testing scheme is required, and the code will resemble the following:
condition setup code1IF (condition1)conditionally executed code1ELSEcondition setup code2IF (condition2)conditionally executed code2ELSEcondition setup code3IF (condition3)conditionally executed code3ELSEcondition setup code4IF (condition4)conditionally executed code4ELSEcondition setup code5IF (condition5)conditionally executed code5aELSEconditionally executed code5bEND—IFEND—IFEND—IFEND—IFEND—IF
It becomes obvious that multiple testing conditions are awkward to code in structured assembly language when standard programming conventions for indentation are followed. The awkward form of coding also makes the task of understanding code and the task of maintaining code more difficult. Consequently, it would be desirable to provide an improved IF statement to be utilized in structured assembly language programming for coding multiple testing conditions.